package com.sikaryofficial.gateway.handler;

import com.sikaryofficial.common.core.web.domain.AjaxResult;
import com.sikaryofficial.gateway.config.properties.AIProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * 获取AI开启状态
 */
@Component
public class AIHandler implements HandlerFunction<ServerResponse> {

    @Autowired
    private AIProperties aiProperties;

    @Override
    public Mono<ServerResponse> handle(ServerRequest request) {
        return ServerResponse
                .status(HttpStatus.OK)
                .body(BodyInserters.fromValue(AjaxResult.success(aiProperties.getEnabled())));
    }
}
